]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dateMenu: Use intervals with non-inclusive ends for date ranges
authorSebastian Keller <skeller@gnome.org>
Thu, 4 Nov 2021 11:42:52 +0000 (12:42 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 30 Nov 2021 02:13:24 +0000 (02:13 +0000)
The ical events, we are comparing these intervals to use the first point
in time after the end of the event as their end time, while the code in
gnome-shell was using the last point in time within the range. This was
causing multi-day events ranging from 0:00 to 0:00 to have a trailing
"..." shown on the last day.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2023>

js/ui/calendar.js
js/ui/dateMenu.js

index ae312c6c08b93fb69505aa73c6c16cf01557d326..0647579053f64ec4058a8187df44fa8154e69fe5 100644 (file)
@@ -47,11 +47,8 @@ function _getBeginningOfDay(date) {
 }
 
 function _getEndOfDay(date) {
-    let ret = new Date(date.getTime());
-    ret.setHours(23);
-    ret.setMinutes(59);
-    ret.setSeconds(59);
-    ret.setMilliseconds(999);
+    const ret = _getBeginningOfDay(date);
+    ret.setDate(ret.getDate() + 1);
     return ret;
 }
 
index 33c054c12f8d58d56a13e6fe4f5cb67847c2672c..f235ba38a2dff252589d3341e01df7dceca32b6a 100644 (file)
@@ -127,9 +127,10 @@ class EventsSection extends St.Button {
     }
 
     setDate(date) {
-        const day = [date.getFullYear(), date.getMonth(), date.getDate()];
-        this._startDate = new Date(...day);
-        this._endDate = new Date(...day, 23, 59, 59, 999);
+        this._startDate =
+            new Date(date.getFullYear(), date.getMonth(), date.getDate());
+        this._endDate =
+            new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1);
 
         this._updateTitle();
         this._reloadEvents();
@@ -156,11 +157,11 @@ class EventsSection extends St.Button {
         const timeSpanDay = GLib.TIME_SPAN_DAY / 1000;
         const now = new Date();
 
-        if (this._startDate <= now && now <= this._endDate)
+        if (this._startDate <= now && now < this._endDate)
             this._title.text = _('Today');
-        else if (this._endDate < now && now - this._endDate < timeSpanDay)
+        else if (this._endDate <= now && now - this._endDate < timeSpanDay)
             this._title.text = _('Yesterday');
-        else if (this._startDate > now && this._startDate - now < timeSpanDay)
+        else if (this._startDate > now && this._startDate - now <= timeSpanDay)
             this._title.text = _('Tomorrow');
         else if (this._startDate.getFullYear() === now.getFullYear())
             this._title.text = this._startDate.toLocaleFormat(sameYearFormat);